package com.calm.ndkstu;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener
{

    // Used to load the 'native-lib' library on application startup.
    static
    {
        System.loadLibrary("ndkstu-lib");
    }
    /**
     * A native method that is implemented by the 'native-lib' native library,
     * which is packaged with this application.
     */
    /**
     * 从ndk直接返回一个字符串
     * @return
     */
    public native String syaHelloworld();

    /**
     * 输入2个字符串做拼接
     * @param name
     * @param say
     * @return
     */
    public native String sayHello(String name,String say);
    public native int getIntArrSum(int[] arr);
    private TextView tvInfo;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        // Example of a call to a native method
        tvInfo = findViewById(R.id.info);
        findViewById(R.id.sayHello).setOnClickListener(this);
        findViewById(R.id.stringCat).setOnClickListener(this);
    }
    @Override
    public void onClick(View view)
    {
        switch (view.getId())
        {
            case R.id.sayHello:
                tvInfo.setText(syaHelloworld());
                break;
            case R.id.stringCat:
                tvInfo.setText(sayHello("Ling",",Nice to meet you!"));
                break;
        }
    }
}
